package com.stox.ui.javafx.charting.model;

import java.util.ArrayList;
import java.util.List;

import javafx.scene.canvas.GraphicsContext;

import com.stox.dto.preference.PreferenceFactory;

public class Grid {

	private boolean visible = true;
	
	private final List<Double> xs = new ArrayList<>();
	
	private final List<Double> ys = new ArrayList<>();

	public List<Double> getXs() {
		return xs;
	}
	
	public List<Double> getYs() {
		return ys;
	}
	
	public void paint(GraphicsContext gc){
		gc.setStroke(PreferenceFactory.get(ChartingPreference.class).getGridColor());
		gc.setLineWidth(0.5);
		if(!xs.isEmpty()){
			for(Double x : xs){
				if(null == x) continue;
				gc.strokeLine(x, 0, x,gc.getCanvas().getHeight());
			}
		}
		
		if(!ys.isEmpty()){
			for(Double y : ys){
				if(null == y) continue;
				gc.strokeLine(0, y, gc.getCanvas().getWidth(), y);
			}
		}
	}

	public boolean isVisible() {
		return visible;
	}

	public void setVisible(boolean visible) {
		this.visible = visible;
	}
	
}
